class Category {
  constructor(id, user_id, name, type, icon, color, is_default, created_at) {
    this.id = id;
    this.user_id = user_id;
    this.name = name;
    this.type = type;
    this.icon = icon;
    this.color = color;
    this.is_default = is_default;
    this.created_at = created_at;
  }

  // Create a Category instance from a database row
  static fromRow(row) {
    return new Category(
      row.id,
      row.user_id,
      row.name,
      row.type,
      row.icon,
      row.color,
      row.is_default,
      row.created_at
    );
  }

  // Convert Category instance to JSON
  toJSON() {
    return {
      id: this.id,
      user_id: this.user_id,
      name: this.name,
      type: this.type,
      icon: this.icon,
      color: this.color,
      is_default: this.is_default,
      created_at: this.created_at
    };
  }
}

module.exports = Category;